/**
 * @projectName study_java
 * @package Observer
 * @className Observer.Test
 */
package Observer;

/**
 * Test
 * @description 测试类
 * @author answer_wx
 * @date 2022/6/28 11:01
 * @version 1.0
 */
public class Test {
    public static void main(String[] args) {
        // 创建一个新的主题
        ConcreteSubject concreteSubject = new ConcreteSubject();
        // 添加订阅者
        concreteSubject.attach(new ConcreteObserver("A", concreteSubject));
        concreteSubject.attach(new ConcreteObserver("B", concreteSubject));
        concreteSubject.attach(new ConcreteObserver("C", concreteSubject));

        // 修改主题状态
        concreteSubject.setSubjectState("测试");
        // 通知所有订阅者
        concreteSubject.notifyObserver();
    }
}